package com.dayang.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.query.Query;

import com.dayang.util.Pagination;


/**
 * 鍩虹鏁版嵁搴撴搷浣滅被
 * 
 * @author hysd
 * 
 */
public interface BaseDAO<T> {

	/**
	 * 淇濆瓨涓�釜瀵硅薄
	 * 
	 * @param o
	 * @return
	 */
	public Serializable save(T o);

	/**
	 * 鍒犻櫎涓�釜瀵硅薄
	 * 
	 * @param o
	 */
	public void delete(T o);

	/**
	 * 鏇存柊涓�釜瀵硅薄
	 * 
	 * @param o
	 */
	public void update(T o);

	/**
	 * 淇濆瓨鎴栨洿鏂板璞�	 * 
	 * @param o
	 */
	public void saveOrUpdate(T o);
	
	public void mergeItem(T o);

	public void flush() ;
	
	public Object load(Class<T> clazz, Serializable id);
	
	/**
	 * 鏌ヨ
	 * 
	 * @param hql
	 * @return
	 */
	public List<T> find(String hql);

	/**
	 * 鏌ヨ闆嗗悎
	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public List<T> find(String hql, Object[] param);
	public List<Object[]> findSomeProperties(String hql, Object[] param);
	public List getSomePropertiesByHqlWithKey(String hql, Map<String, Object> map);
	public List<Object> findOnePropertie(String hql, Object[] param);
	/**
	 * 鏌ヨ闆嗗悎
	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public List<T> find(String hql, List<Object> param);
	public List<Object[]> findSomeProperties(String hql, List<Object> param);

	/**
	 * 鏌ヨ闆嗗悎(甯﹀垎椤�
	 * 
	 * @param hql
	 * @param param
	 * @param page
	 *            鏌ヨ绗嚑椤�	 * @param rows
	 *            姣忛〉鏄剧ず鍑犳潯璁板綍
	 * @return
	 */
	public List<T> find(String hql, Object[] param, Integer page, Integer rows);

	/**
	 * 鏌ヨ闆嗗悎(甯﹀垎椤�
	 * 
	 * @param hql
	 * @param param
	 * @param page
	 * @param rows
	 * @return
	 */
	public List<T> find(String hql, List<Object> param, Integer page,
			Integer rows);
	
	public List<T> findAll(Class clazz);

	public List<T> queryHqlByPage(String hql, Pagination pagination, Map<String, Object> map);
	
	public int queryCount(String hql,Map<String,Object> maps);

	/**
	 * 鑾峰緱涓�釜瀵硅薄
	 * 
	 * @param c
	 *            瀵硅薄绫诲瀷
	 * @param id
	 * @return Object
	 */
	public T get(Class<T> c, Serializable id);

	/**
	 * 鑾峰緱涓�釜瀵硅薄
	 * 
	 * @param hql
	 * @param param
	 * @return Object
	 */
	public T get(String hql, Object[] param);

	/**
	 * 鑾峰緱涓�釜瀵硅薄
	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public T get(String hql, List<Object> param);

	/**
	 * select count(*) from 绫�	 * 
	 * @param hql
	 * @return
	 */
	public Long count(String hql);

	/**
	 * select count(*) from 绫�	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public Long count(String hql, Object[] param);

	/**
	 * select count(*) from 绫�	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public Long count(String hql, List<Object> param);

	/**
	 * 鎵цHQL璇彞
	 * 
	 * @param hql
	 * @return 鍝嶅簲鏁扮洰
	 */
	public Integer executeHql(String hql);

	/**
	 * 鎵цHQL璇彞
	 * 
	 * @param hql
	 * @param param
	 * @return 鍝嶅簲鏁扮洰
	 */
	public Integer executeHql(String hql, Object[] param);

	/**
	 * HQL查询
	 * 
	 * @param hql
	 * @param param
	 * @return
	 */
	public Integer executeHql(String hql, List<Object> param);
	
	public int executeHql(String hql, Map<String,Object> map);
	public Integer executeSql(String sql, Map<String,Object> map);

	public List<T> getByHqlWithKey(String hql, Pagination pagination, Map<String, Object> map);
	public List<T> getByHqlWithIndex(String hql, Pagination pagination, Object... objects);
	public Query getHqlQuery(String hql,Map<String,Object> map);
	public Query getHqlQuery(String hql, Object... objects);
}